<?php
// +----------------------------------------------------------------------
// | QSCMS
// +----------------------------------------------------------------------
// | Copyright (c)  2025 https://www.qqss.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed QSCMS is not free software, commercial use must purchase official license from official website to avoid unnecessary legal disputes.
// +----------------------------------------------------------------------
// | Author: Contract 990504246@qq.com
// +----------------------------------------------------------------------

namespace app\service\user;

use app\common\util\TokenAuth;

/**
 * 公共用户服务层
 * class UserCommonService
 */
class UserCommonService
{

    /**
     * 创建token
     * @param $user
     * @return array
     */
    public function createToken($user, $type = 'user')
    {
        match ($type) {
            'admin' => $expire = 48,
            default => $expire = 24 * 365,
        };
        return [
            'access_token' => TokenAuth::createToken($user['id'], $type, $user, 3600 * $expire)['token']
        ];
    }
}
